package com.hxw.sample.opengl30;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;

public class MyGLSurfaceView extends GLSurfaceView{

    public MyGLSurfaceView(Context context) {
        this(context, null);
    }
//    private TriangleRender mRender = new TriangleRender();//渲染一个最简单的三角形
//    private TriangleRenderV2_MAT mRender = new TriangleRenderV2_MAT();//支持矩阵变化，缩放，平移，镜像，旋转
//    private TriangleRenderV3_VBO mRender = new TriangleRenderV3_VBO();//支持VBO
//    private TriangleRenderV4_EBO mRender = new TriangleRenderV4_EBO();//支持EBO
//    private TriangleRenderV4_EBO_V2 mRender = new TriangleRenderV4_EBO_V2();//利用EBO绘制四边形
//    private TriangleRenderV5_VAO mRender = new TriangleRenderV5_VAO();//支持VA0
//    private TriangleRenderV4_EBO_V3 mRender = new TriangleRenderV4_EBO_V3();//利用EBO绘制四边形

//    private TextureRenderV1 mRender = new TextureRenderV1();//渲染图片
//    private TextureRenderV2WB mRender = new TextureRenderV2WB();//黑白滤镜
//    private TextureRenderV3Alpha mRender = new TextureRenderV3Alpha();//透明度设置
//    private TextureRenderV4 mRender = new TextureRenderV4();//着色器不变，绘制多张图片
//    private TextureRenderV5 mRender = new TextureRenderV5();//解决图片拉伸问题方案：视口裁剪
    private TextureRenderV5_1 mRender = new TextureRenderV5_1();//解决图片拉伸问题方案：投影变换

    public MyGLSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setEGLContextClientVersion(3);//设置OpenGL版本为3.0,如果不设置的话可能会报错
        setRenderer(mRender);
    }

    public void onDestroy() {
        if (mRender != null){
            mRender.onDestroy();
        }
    }
}
